package com.staticData;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.orderMgr.bean.OfFood;
import com.orderMgr.bean.OfFoodCriteria;
import com.orderMgr.bean.OfRestaurant;
import com.orderMgr.bean.OfRestaurantCriteria;
import com.orderMgr.bean.UserOrderFood;
import com.orderMgr.dao.OfFoodDAO;
import com.orderMgr.dao.OfOrderDetailDAO;
import com.orderMgr.dao.OfRestaurantDAO;
import com.util.SpringContext;

/**
 *@title      	标题：静态数据
 *@description 	描述：
 *@author 	  	作者 ：wuxionghao
 *@createTime 	创建时间：2012-1-7下午03:10:14
 *@version    	版本：v1.0
 */
public class StaticObject implements Serializable{
	
	private static final long serialVersionUID = 1L;
	
	public static Map<String,Object> resInfo = new HashMap<String,Object>(); 
	/**
	 * 餐厅信息
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public static Map<String,Object> infomation(){
		OfRestaurantCriteria ofRes = new OfRestaurantCriteria();
		ofRes.createCriteria().andOfIdIsNotNull();
		OfRestaurantDAO ofRestaurantDAO = (OfRestaurantDAO) SpringContext.getContext().getBean("ofRestaurantDAO");
		List<OfRestaurant> resList = ofRestaurantDAO.selectByExample(ofRes);
		resInfo.put("res",resList );
		return resInfo;
	}
	/**
	 * 加载餐厅信息
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public static List<OfRestaurant> getResInfo(){
		List<OfRestaurant> res = new ArrayList<OfRestaurant>();
		res = (List<OfRestaurant>)resInfo.get("res");
		return res;
	}
	
	/**
	 * 菜单信息
	 * @author meishuangyan
	 */
	@SuppressWarnings("unchecked")
	public static Map<String,Object> foodInfo(){
		OfFoodCriteria ofRes = new OfFoodCriteria();
		ofRes.createCriteria().andOfIdIsNotNull();
		OfFoodDAO ofFoodDAO = (OfFoodDAO)SpringContext.getContext().getBean("OfFoodDAO");
		OfRestaurantDAO ofRestaurantDAO = (OfRestaurantDAO) SpringContext.getContext().getBean("ofRestaurantDAO");
		List<OfFood> foodList=ofFoodDAO.selectByExample(ofRes);
		List<List> list = new ArrayList<List>();
		for(int i=0;i<foodList.size();i++){
			OfFood food=foodList.get(i);
			OfRestaurant ofRestaurtant=ofRestaurantDAO.selectByPrimaryKey(food.getOfRestaurantId());
			List info=new ArrayList();
			//0菜品id
			info.add(food.getOfId());
			//1菜品名称
			info.add(food.getOfFoodName());
			//2菜品价格
			info.add(food.getOfFoodPrice());
			//3菜品图片
			info.add(food.getOfFoodPic());
			//4餐馆id
			info.add(food.getOfRestaurantId());
			//5餐馆名称
			info.add(ofRestaurtant.getOfName());
			//6餐馆电话
			info.add(ofRestaurtant.getOfTel());
			list.add(info);
		}
		resInfo.put("resFood",list);
		return resInfo;
	}
	
	/**
	 * 加载菜单信息
	 */
	@SuppressWarnings("unchecked")
	public static List<List> getFoodInfo(){
		List<List> list = new ArrayList<List>();
		list =(List<List>) resInfo.get("resFood");
		return list;
	}
}
